home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / MACVOGL- / EXAMPLES / MORETXT2.C < prev    next >
C/C++ Source or Header  |  1992-07-19  |  2KB  |  171 lines

  1. #include <stdio.h>
  2.  
  3. #ifdef SGI
  4. #include "gl.h"
  5. #include "device.h"
  6. #else
  7. #include "vogl.h"
  8. #include "vodevice.h"
  9. #endif
  10.  
  11. /*
  12.  * demonstrate still more features of text
  13.  */
  14. main(argc, argv)
  15.     int    argc;
  16.     char    **argv;
  17. {
  18.     
  19.     winopen("moretxt2");
  20.  
  21.     unqdevice(INPUTCHANGE);
  22.     qdevice(KEYBD);
  23.  
  24.     if (argc == 2)
  25.         hfont(argv[1]);
  26.     else
  27.         hfont("futura.l");
  28.  
  29.     htextsize(0.03, 0.04);
  30.  
  31.     ortho2(0.0, 1.0, 0.0, 1.0);
  32.  
  33.  
  34.     color(RED);
  35.     clear();
  36.  
  37.  
  38.     drawstuff();
  39.  
  40.     /* Now do it all with the text rotated .... */
  41.  
  42.     htextang(45.0);
  43.     drawstuff();
  44.  
  45.     htextang(160.0);
  46.     drawstuff();
  47.  
  48.     htextang(270.0);
  49.     drawstuff();
  50.  
  51.     /* Now with a single character */
  52.  
  53.     htextang(0.0);
  54.     drawstuff2();
  55.  
  56.     htextang(45.0);
  57.     drawstuff2();
  58.  
  59.     htextang(160.0);
  60.     drawstuff2();
  61.  
  62.     htextang(270.0);
  63.     drawstuff2();
  64.  
  65.     gexit();
  66. }
  67.  
  68. drawstuff()
  69. {
  70.     short    val;
  71.  
  72.     color(BLACK);
  73.     rectf(0.1, 0.1, 0.9, 0.9);
  74.     color(WHITE);
  75.     move2(0.1, 0.5);
  76.     draw2(0.9, 0.5);
  77.     move2(0.5, 0.1);
  78.     draw2(0.5, 0.9);
  79.  
  80.     color(GREEN);
  81.     move2(0.5, 0.5);
  82.     hleftjustify(1);
  83.     hcharstr("This is Left Justified text");
  84.  
  85.     qread(&val);
  86.  
  87.     color(BLACK);
  88.     rectf(0.1, 0.1, 0.9, 0.9);
  89.     color(WHITE);
  90.     move2(0.1, 0.5);
  91.     draw2(0.9, 0.5);
  92.     move2(0.5, 0.1);
  93.     draw2(0.5, 0.9);
  94.  
  95.     color(YELLOW);
  96.     move2(0.5, 0.5);
  97.     hcentertext(1);
  98.     hcharstr("This is Centered text");
  99.     hcentertext(0);
  100.  
  101.     qread(&val);
  102.  
  103.     color(BLACK);
  104.     rectf(0.1, 0.1, 0.9, 0.9);
  105.     color(WHITE);
  106.     move2(0.1, 0.5);
  107.     draw2(0.9, 0.5);
  108.     move2(0.5, 0.1);
  109.     draw2(0.5, 0.9);
  110.  
  111.     color(MAGENTA);
  112.     move2(0.5, 0.5);
  113.     hrightjustify(1);
  114.     hcharstr("This is Right Justified text");
  115.     hrightjustify(0);
  116.  
  117.     qread(&val);
  118. }
  119.  
  120. drawstuff2()
  121. {
  122.     short    val;
  123.  
  124.     color(BLACK);
  125.     rectf(0.1, 0.1, 0.9, 0.9);
  126.     color(WHITE);
  127.     move2(0.1, 0.5);
  128.     draw2(0.9, 0.5);
  129.     move2(0.5, 0.1);
  130.     draw2(0.5, 0.9);
  131.  
  132.     color(GREEN);
  133.     move2(0.5, 0.5);
  134.     hleftjustify(1);
  135.     hdrawchar('B');
  136.  
  137.     qread(&val);
  138.  
  139.     color(BLACK);
  140.     rectf(0.1, 0.1, 0.9, 0.9);
  141.     color(WHITE);
  142.     move2(0.1, 0.5);
  143.     draw2(0.9, 0.5);
  144.     move2(0.5, 0.1);
  145.     draw2(0.5, 0.9);
  146.  
  147.     color(YELLOW);
  148.     move2(0.5, 0.5);
  149.     hcentertext(1);
  150.     hdrawchar('B');
  151.     hcentertext(0);
  152.  
  153.     qread(&val);
  154.  
  155.     color(BLACK);
  156.     rectf(0.1, 0.1, 0.9, 0.9);
  157.     color(WHITE);
  158.     move2(0.1, 0.5);
  159.     draw2(0.9, 0.5);
  160.     move2(0.5, 0.1);
  161.     draw2(0.5, 0.9);
  162.  
  163.     color(MAGENTA);
  164.     move2(0.5, 0.5);
  165.     hrightjustify(1);
  166.     hdrawchar('B');
  167.     hrightjustify(0);
  168.  
  169.     qread(&val);
  170. }
  171.